/*
 * BaseCityInfoBO.java 
 * 
 * Copyright 2009 Wangfeng Beijing Inc. 
 * All rights reserved. 
 * 
 * Created on 2012-07-07
 */

package com.bjtech.domain.query;

import org.ssi.web.util.QuerySpecTpl;

import com.bjtech.web.util.SelectBean;

/**
 * 功能概述:城市基础信息 <br>
 * 
 * @author 王峰
 */

public class BaseCityInfoQuerySpec extends SelectBean {
	/* */
	private Long id;
	/* */
	private Long p_index;
	/* */
	private String p_name;
	/* */
	private String s_name;
	/* */
	private String p_code;
	/* */
	private Long par_index;

	@Override
	public void queryParamString() {
		StringBuilder fromPart = new StringBuilder(" where 1=1");

		if (this.isAll != null && this.isAll.intValue() != 1) {
			if (QuerySpecTpl.isValid(id)) {
				fromPart.append(" and a.id = ");
				fromPart.append(id);
			}

			if (QuerySpecTpl.isValid(p_index)) {
				fromPart.append(" and a.p_index = ");
				fromPart.append(p_index);
			}

			if (QuerySpecTpl.isValid(p_name)) {
				fromPart.append(" and a.p_name like ");
				fromPart.append(" CONCAT('%','");
				fromPart.append(p_name);
				fromPart.append("','%')");
			}

			if (QuerySpecTpl.isValid(s_name)) {
				fromPart.append(" and a.s_name like ");
				fromPart.append(" CONCAT('%','");
				fromPart.append(s_name);
				fromPart.append("','%')");
			}

			if (QuerySpecTpl.isValid(p_code)) {
				fromPart.append(" and a.p_code like ");
				fromPart.append(" CONCAT('%','");
				fromPart.append(p_code);
				fromPart.append("','%')");
			}

			if (QuerySpecTpl.isValid(par_index)) {
				fromPart.append(" and a.par_index = ");
				fromPart.append(par_index);
			}

			if (QuerySpecTpl.isValid(this.direction)
					&& QuerySpecTpl.isValid(this.sort)) {
				fromPart.append(" order by ");
				fromPart.append(this.sort);
				fromPart.append(" ");
				fromPart.append(this.direction);
			} else {
				fromPart.append(" order by ");
				fromPart.append("id");
				fromPart.append(" ");
				fromPart.append("asc");

			}
		}
		super.setQueryString(fromPart.toString());
	}

	public Long getId() {
		return this.id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Long getP_index() {
		return this.p_index;
	}

	public void setP_index(Long p_index) {
		this.p_index = p_index;
	}

	public String getP_name() {
		return this.p_name;
	}

	public void setP_name(String p_name) {
		this.p_name = p_name;
	}

	public String getS_name() {
		return this.s_name;
	}

	public void setS_name(String s_name) {
		this.s_name = s_name;
	}

	public String getP_code() {
		return this.p_code;
	}

	public void setP_code(String p_code) {
		this.p_code = p_code;
	}

	public Long getPar_index() {
		return this.par_index;
	}

	public void setPar_index(Long par_index) {
		this.par_index = par_index;
	}
}
